package com.huike.controller.station;


import com.huike.dto.StationDto;
import com.huike.result.PageResult;
import com.huike.result.Result;
import com.huike.service.StationsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/system/station")
public class StationsController {
    @Autowired
    private StationsService stationsService;

    /**
     * 岗位分页查询
     * @param dto
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> findAll(StationDto dto) {
        PageResult pageResult = stationsService.findAll(dto);
        return Result.success(pageResult);
    }

    /**
     * 岗位状态获取
     * @return
     */
    @GetMapping("/status")
    public Result dictLabel() {
        String dictLabel = "sys_job_status";
        return stationsService.dictlabr(dictLabel);
    }

    /**
     * 添加岗位
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody StationDto dto) {
        stationsService.add(dto);
        return Result.success("添加成功");
    }

    /**
     * 删除岗位
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    public Result deleteById(@PathVariable Integer ids) {

        stationsService.deleteById(ids);
        return Result.success();
    }

    /**
     * 修改岗位
     * @param dto
     * @return
     */
    @PutMapping("/update")
    public Result updateStation(@RequestBody StationDto dto){
        stationsService.updateStation(dto);
        return Result.success();
}

    /**
     * 数据回显
     * @param id
     * @return
     */
    @GetMapping("/find/{id}")
public Result findById(@PathVariable Integer id){
      return   stationsService.findById(id);
}
}
